// pages/walletRecharge/walletRecharge.js
var app = getApp();
var req = require("../../utils/req.js");
var url = require("../../utils/url.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    createTime: '',
    orderNumber: '',
    price: '',
    state:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(e) {
    var that = this;
    that.setData({
      state: "门店消费",
      orderNumber: e.orderNumber,
      price: e.price,
      createTime: e.createTime,
    })
  },

  inputPrice: function(e) {

    var money;
    if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) { //正则验证，提现金额小数点后不能大于两位数字
      money = e.detail.value;
    } else {
      money = e.detail.value.substring(0, e.detail.value.length - 1);
    }
    this.setData({
      money: money,
    })

  },
  submitInfo: function(e) {
    const data = {
      orderNumber: this.data.orderNumber
    }

    wx.showModal({
      title: '提示',
      content: '是否确认充值',
      success(res) {
        if (res.confirm) {
          req.userRequest("请稍等", 'POST', url.user['userScanQrcoderPay'], data, function back(res) {
            app.globalData.isNewUserInfo = true;
            wx.showToast({
              title: res.msg,
              duration: 1500,
              success: function () {
                setTimeout(function () {
                  wx.navigateTo({
                    url: '/pages/mine/mine',
                  })
                }, 1500);
              }
            })
          })
        }
      }
    })
  },
})